package com.library.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.NotBlank;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 * <p>
 * 用户实体类
 * </p>
 *
 * @author LDH
 * @since 2022-05-12
 */
@ApiModel(value = "User对象", description = "")
@Data
public class User implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("主键")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @NotNull(message = "用户姓名不能为空！")
    @NotBlank(message = "用户姓名不能为空！")
    @ApiModelProperty("用户姓名，不能为空！")
    private String name;

    @ApiModelProperty("用户年龄")
    private Integer age;

    @ApiModelProperty("用户性别，0是男生，1是女生")
    private Integer sex;

    @NotNull(message = "用户电话不能为空！")
    @Pattern(regexp = "^1(?:3\\d|4[4-9]|5[0-35-9]|6[67]|7[013-8]|8\\d|9\\d)\\d{8}$",message = "手机号码不符合规范")
    @ApiModelProperty("用户手机号码，不能为空！")
    private String phone;

    @NotNull(message = "用户邮箱不能为空！")
    @Pattern(regexp = "^([a-zA-Z]|[0-9])(\\w|\\-)+@[a-zA-Z0-9]+\\.([a-zA-Z]{2,4})$",message = "邮箱格式不正确")
    @ApiModelProperty("用户邮箱，不能为空！")
    private String mailbox;

    @NotNull(message = "用户地址不能为空！")
    @ApiModelProperty("用户地址，不能为空！")
    private String address;

    @ApiModelProperty("用户此时借了几本书")
    private Integer booksNum;

    @ApiModelProperty("用户信誉，默认3")
    private Integer credit;

    @ApiModelProperty("用户昵称")
    private String nikName;

    @NotNull(message = "用户账号不能为空！")
    @Pattern(regexp = "^[0-9]{6,10}$",message = "账号必须是6-10位的纯数字")
    @ApiModelProperty("用户账号，不能为空！6-10位纯数字")
    private String account;

    @NotNull(message = "用户密码不能为空！")
    @Pattern(regexp = "^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,10}$",message = "密码要包含英文和中文，6~10位")
    @ApiModelProperty("用户密码，不能为空！包含6-10位数字和字母")
    private String password;

    @ApiModelProperty("用户头像")
    private String head;

}
